package com.whfc.wxmp.api.base.controller;

import com.whfc.common.base.BaseController;
import com.whfc.common.result.Result;
import com.whfc.common.result.ResultUtil;
import com.whfc.common.util.SessionAttr;
import com.whfc.fuum.entity.WxUser;
import com.whfc.wxmp.annotation.CurrentWxUser;
import com.whfc.wxmp.api.base.service.WxFileService;
import com.whfc.wxmp.util.RequestConetxtUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 图片上传
* @Description: 
* @author guodong_sun 
* @date 2019年8月5日
 */
@RestController
@RequestMapping("/mp/api/file")
public class WxFileController extends BaseController{
	
	@Autowired
	private WxFileService wxFileService;
	/**
	 * 图片上传
	 * @throws IOException 
	 */
	@PostMapping("/uploadImg")
	public Result uploadImg(@CurrentWxUser WxUser user , MultipartFile file) throws IOException {
		logger.info("WXMPUA|{}|{}|{}|{}|{}",
				user.getId(), RequestConetxtUtil.getAppType(), RequestConetxtUtil.getPage(),
				"图片上传", RequestConetxtUtil.getParameters());
		String path = wxFileService.uploadImg(file);
		return ResultUtil.success(path);
	}
}
